/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyClass;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author HuuTai_it
 */
public class MainMenu extends Canvas{ 
    
    private Control control;
    
    private Image choiceItem = Image.createImage("/MyPicture/choice.png");
    private Image mainmenuscreen = Image.createImage("/MyPicture/mainmenuscreen.png");
    
    private int choose = 0;
    
    public MainMenu(Control control) throws Exception {
        
        setFullScreenMode(true);
        this.control = control;
    }
    
    public  void keyPressed(int keyCode){
        
        switch(getGameAction(keyCode)) {
            
            case UP:
                if(choose-- == 0)
                    choose = 6;
                repaint();
                break;
                
            case DOWN:
                if(choose++ == 6)
                    choose = 0;
                repaint();
                break;
                
            case FIRE:
                switch(choose) {
                    case 0:
                        control.showLoadingScreen(true);
                        break;
                    case 1:
                        control.showLoadingScreen(false);
                        break;
                    case 2:
                        control.showHighScoresScreen();
                        break;
                    case 3:
                        control.showSettingScreen();
                        break;
                    case 4: 
                        control.showAboutScreen();                       
                        break;
                    case 5:                       
                        control.showHelpScreen(); 
                        break;
                    case 6:        
                        control.exitGame(); 
                        break;
                }
                break;
        }
    }
    
    public void paint(Graphics g) {
        
        g.drawImage(mainmenuscreen, 0, 0,  Graphics.TOP | Graphics.LEFT);
        g.drawImage(choiceItem, 30, 100 + 30 * choose,  Sprite.TRANS_NONE);
    }
}
